package com.blank.shop.nacos.config;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author _blank
 */
@Configuration
@AutoConfigureAfter(value = {RestTemplateAutoConfiguration.class})
public class RestTemplateConfig {

    /**
     * LoadBalanced 若使用注册中心，就需要加上这个注解
     *
     * @param restTemplateBuilder org.springframework.boot.web.client.RestTemplateBuilder
     * @return org.springframework.web.client.RestTemplate
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
        return restTemplateBuilder.build();
    }

}